package com.tsystems.train.bean;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.tsystems.train.entity.TimeTableElement;
import com.tsystems.train.entity.Train;

public class PathNode {

	private Train train;

	private TimeTableElement tte;

	private String number;
	private String departureStation;
	private String departureTime;
	private String arrivalStation;
	private String arrivalTime;

	private String result;

	public PathNode(Train train, String departureStation, Date departureTime, String arrivalStation, Date arrivalTime) {
		super();
		this.train = train;
		number = train.getNumber();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
				"HH:mm  dd:MM:yyyy");
		this.departureStation = departureStation;
		this.departureTime = simpleDateFormat.format(departureTime);
		this.arrivalStation = arrivalStation;
		this.arrivalTime = simpleDateFormat.format(arrivalTime);
		this.tte = null;

		result = "Train: " + number;

	}

	public PathNode(Train train, TimeTableElement tte) {
		super();
		this.train = train;
		this.tte = tte;

		number = "Trace:";
		departureStation = tte.getDepartureStation().getName();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
				"HH:mm  dd:MM:yyyy");

		
		departureTime = simpleDateFormat.format(tte.getDepartureTime());
		arrivalStation = tte.getArrivalStation().getName();
		arrivalTime = simpleDateFormat.format(tte.getArrivalTime());
		result = "Path element: " + departureStation + " " + departureTime
				+ " " + arrivalStation + " " + arrivalTime;
	}

	public Train getTrain() {
		return train;
	}

	public void setTrain(Train train) {
		this.train = train;
	}

	public TimeTableElement getTte() {
		return tte;
	}

	public void setTte(TimeTableElement tte) {
		this.tte = tte;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getDepartureStation() {
		return departureStation;
	}

	public void setDepartureStation(String departureStation) {
		this.departureStation = departureStation;
	}

	public String getDepartureTime() {
		return departureTime;
	}

	public void setDepartureTime(String departureTime) {
		this.departureTime = departureTime;
	}

	public String getArrivalStation() {
		return arrivalStation;
	}

	public void setArrivalStation(String arrivalStation) {
		this.arrivalStation = arrivalStation;
	}

	public String getArrivalTime() {
		return arrivalTime;
	}

	public void setArrivalTime(String arrivalTime) {
		this.arrivalTime = arrivalTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((arrivalStation == null) ? 0 : arrivalStation.hashCode());
		result = prime * result
				+ ((arrivalTime == null) ? 0 : arrivalTime.hashCode());
		result = prime
				* result
				+ ((departureStation == null) ? 0 : departureStation.hashCode());
		result = prime * result
				+ ((departureTime == null) ? 0 : departureTime.hashCode());
		result = prime * result + ((number == null) ? 0 : number.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PathNode other = (PathNode) obj;
		if (arrivalStation == null) {
			if (other.arrivalStation != null)
				return false;
		} else if (!arrivalStation.equals(other.arrivalStation))
			return false;
		if (arrivalTime == null) {
			if (other.arrivalTime != null)
				return false;
		} else if (!arrivalTime.equals(other.arrivalTime))
			return false;
		if (departureStation == null) {
			if (other.departureStation != null)
				return false;
		} else if (!departureStation.equals(other.departureStation))
			return false;
		if (departureTime == null) {
			if (other.departureTime != null)
				return false;
		} else if (!departureTime.equals(other.departureTime))
			return false;
		if (number == null) {
			if (other.number != null)
				return false;
		} else if (!number.equals(other.number))
			return false;
		return true;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	
	

}
